﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace SatisGonderim
{
    public class Mikro
    {
        public void TableCreate(DateTime tarih)
        {
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            TableCreate(tarih, tableName);
        }

        public void TableCreate(DateTime tarih, string tableName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND type in (N'U'))");
            sb.Append(" BEGIN ");
            sb.Append(" CREATE TABLE [dbo].[S_{0}](");
            sb.Append("	[sth_RECno] [int] IDENTITY(1,1) NOT NULL,");
            sb.Append(" [sth_RECid_DBCno] [smallint] NOT NULL, ");
            sb.Append(" [sth_RECid_RECno] [int] NOT NULL, ");
            sb.Append(" [sth_SpecRECno] [int] NULL, ");
            sb.Append(" [sth_iptal] [bit] NULL, ");
            sb.Append(" [sth_fileid] [smallint] NULL, ");
            sb.Append(" [sth_hidden] [bit] NULL, ");
            sb.Append(" [sth_kilitli] [bit] NULL, ");
            sb.Append(" [sth_degisti] [bit] NULL, ");
            sb.Append(" [sth_checksum] [int] NULL, ");
            sb.Append(" [sth_create_user] [smallint] NULL, ");
            sb.Append(" [sth_create_date] [datetime] NULL, ");
            sb.Append(" [sth_lastup_user] [smallint] NULL, ");
            sb.Append(" [sth_lastup_date] [datetime] NULL, ");
            sb.Append(" [sth_special1] [nvarchar](4) NULL, ");
            sb.Append(" [sth_special2] [nvarchar](4) NULL, ");
            sb.Append(" [sth_special3] [nvarchar](4) NULL, ");
            sb.Append(" [sth_firmano] [int] NULL, ");
            sb.Append(" [sth_subeno] [int] NULL, ");
            sb.Append(" [sth_tarih] [datetime] NULL, ");
            sb.Append(" [sth_tip] [tinyint] NULL, ");
            sb.Append(" [sth_cins] [tinyint] NULL, ");
            sb.Append(" [sth_normal_iade] [tinyint] NULL, ");
            sb.Append(" [sth_evraktip] [tinyint] NULL, ");
            sb.Append(" [sth_evrakno_seri] [nvarchar](6) NULL, ");
            sb.Append(" [sth_evrakno_sira] [int] NULL, ");
            sb.Append(" [sth_satirno] [int] NULL, ");
            sb.Append(" [sth_belge_no] [nvarchar](20) NULL, ");
            sb.Append(" [sth_belge_tarih] [datetime] NULL, ");
            sb.Append(" [sth_stok_kod] [nvarchar](25) NULL, ");
            sb.Append(" [sth_isk_mas1] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas2] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas3] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas4] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas5] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas6] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas7] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas8] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas9] [tinyint] NULL, ");
            sb.Append(" [sth_isk_mas10] [tinyint] NULL, ");
            sb.Append(" [sth_sat_iskmas1] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas2] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas3] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas4] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas5] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas6] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas7] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas8] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas9] [bit] NULL, ");
            sb.Append(" [sth_sat_iskmas10] [bit] NULL, ");
            sb.Append(" [sth_pos_satis] [bit] NULL, ");
            sb.Append(" [sth_promosyon_fl] [bit] NULL, ");
            sb.Append(" [sth_cari_cinsi] [tinyint] NULL, ");
            sb.Append(" [sth_cari_kodu] [nvarchar](25) NULL, ");
            sb.Append(" [sth_cari_grup_no] [tinyint] NULL, ");
            sb.Append(" [sth_isemri_gider_kodu] [nvarchar](25) NULL, ");
            sb.Append(" [sth_plasiyer_kodu] [nvarchar](25) NULL, ");
            sb.Append(" [sth_har_doviz_cinsi] [tinyint] NULL, ");
            sb.Append(" [sth_har_doviz_kuru] [float] NULL, ");
            sb.Append(" [sth_alt_doviz_kuru] [float] NULL, ");
            sb.Append(" [sth_stok_doviz_cinsi] [tinyint] NULL, ");
            sb.Append(" [sth_stok_doviz_kuru] [float] NULL, ");
            sb.Append(" [sth_miktar] [float] NULL, ");
            sb.Append(" [sth_miktar2] [float] NULL, ");
            sb.Append(" [sth_birim_pntr] [tinyint] NULL, ");
            sb.Append(" [sth_tutar] [float] NULL, ");
            sb.Append(" [sth_iskonto1] [float] NULL, ");
            sb.Append(" [sth_iskonto2] [float] NULL, ");
            sb.Append(" [sth_iskonto3] [float] NULL, ");
            sb.Append(" [sth_iskonto4] [float] NULL, ");
            sb.Append(" [sth_iskonto5] [float] NULL, ");
            sb.Append(" [sth_iskonto6] [float] NULL, ");
            sb.Append(" [sth_masraf1] [float] NULL, ");
            sb.Append(" [sth_masraf2] [float] NULL, ");
            sb.Append(" [sth_masraf3] [float] NULL, ");
            sb.Append(" [sth_masraf4] [float] NULL, ");
            sb.Append(" [sth_vergi_pntr] [tinyint] NULL, ");
            sb.Append(" [sth_vergi] [float] NULL, ");
            sb.Append(" [sth_masraf_vergi_pntr] [tinyint] NULL, ");
            sb.Append(" [sth_masraf_vergi] [float] NULL, ");
            sb.Append(" [sth_netagirlik] [float] NULL, ");
            sb.Append(" [sth_odeme_op] [int] NULL, ");
            sb.Append(" [sth_aciklama] [nvarchar](50) NULL, ");
            sb.Append(" [sth_sip_recid_dbcno] [smallint] NULL, ");
            sb.Append(" [sth_sip_recid_recno] [int] NULL, ");
            sb.Append(" [sth_fat_recid_dbcno] [smallint] NULL, ");
            sb.Append(" [sth_fat_recid_recno] [int] NULL, ");
            sb.Append(" [sth_giris_depo_no] [int] NULL, ");
            sb.Append(" [sth_cikis_depo_no] [int] NULL, ");
            sb.Append(" [sth_malkbl_sevk_tarihi] [datetime] NULL, ");
            sb.Append(" [sth_cari_srm_merkezi] [nvarchar](25) NULL, ");
            sb.Append(" [sth_stok_srm_merkezi] [nvarchar](25) NULL, ");
            sb.Append(" [sth_fis_tarihi] [datetime] NULL, ");
            sb.Append(" [sth_fis_sirano] [int] NULL, ");
            sb.Append(" [sth_vergisiz_fl] [bit] NULL, ");
            sb.Append(" [sth_maliyet_ana] [float] NULL, ");
            sb.Append(" [sth_maliyet_alternatif] [float] NULL, ");
            sb.Append(" [sth_maliyet_orjinal] [float] NULL, ");
            sb.Append(" [sth_adres_no] [int] NULL, ");
            sb.Append(" [sth_parti_kodu] [nvarchar](25) NULL, ");
            sb.Append(" [sth_lot_no] [int] NULL, ");
            sb.Append(" [sth_kons_recid_dbcno] [smallint] NULL, ");
            sb.Append(" [sth_kons_recid_recno] [int] NULL, ");
            sb.Append(" [sth_proje_kodu] [nvarchar](25) NULL, ");
            sb.Append(" [sth_exim_kodu] [nvarchar](25) NULL, ");
            sb.Append(" [sth_otv_pntr] [tinyint] NULL, ");
            sb.Append(" [sth_otv_vergi] [float] NULL, ");
            sb.Append(" [sth_brutagirlik] [float] NULL, ");
            sb.Append(" [sth_disticaret_turu] [tinyint] NULL, ");
            sb.Append(" [sth_otvtutari] [float] NULL, ");
            sb.Append(" [sth_otvvergisiz_fl] [bit] NULL, ");
            sb.Append(" [sth_oiv_pntr] [tinyint] NULL, ");
            sb.Append(" [sth_oiv_vergi] [float] NULL, ");
            sb.Append(" [sth_oivvergisiz_fl] [bit] NULL, ");
            sb.Append(" [sth_fiyat_liste_no] [int] NULL, ");
            sb.Append(" [sth_oivtutari] [float] NULL, ");
            sb.Append(" [sth_Tevkifat_turu] [tinyint] NULL, ");
            sb.Append(" [sth_nakliyedeposu] [int] NULL, ");
            sb.Append(" [sth_nakliyedurumu] [tinyint] NULL, ");
            sb.Append(" [sth_yetkili_recid_dbcno] [smallint] NULL, ");
            sb.Append(" [sth_yetkili_recid_recno] [int] NULL, ");
            sb.Append(" [sth_taxfree_fl] [bit] NULL, ");
            sb.Append(" [sth_ilave_edilecek_kdv] [float] NULL, ");
            sb.Append(" CONSTRAINT [NDX_S_{0}_00] PRIMARY KEY CLUSTERED ");
            sb.Append(" ( ");
            sb.Append("	[sth_RECno] ASC ");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] ");
            sb.Append(" ) ON [PRIMARY] ");
            sb.Append(" END ");
            sb.Append(";");
            sb.Append("IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_01') ");
            sb.Append(" CREATE UNIQUE NONCLUSTERED INDEX [NDX_S_{0}_01] ON [dbo].[S_{0}] ");
            sb.Append(" ( ");
            sb.Append("	[sth_RECid_DBCno] ASC,");
            sb.Append("	[sth_RECid_RECno] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] ");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_02')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_02] ON [dbo].[S_{0}] ");
            sb.Append("(");
            sb.Append("	[sth_tarih] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_03')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_03] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_cari_cinsi] ASC,");
            sb.Append("	[sth_cari_kodu] ASC,");
            sb.Append("	[sth_tarih] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_04')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_04] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_stok_kod] ASC,");
            sb.Append("	[sth_tarih] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_05')");
            sb.Append(" CREATE UNIQUE NONCLUSTERED INDEX [NDX_S_{0}_05] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_evraktip] ASC,");
            sb.Append("	[sth_evrakno_seri] ASC,");
            sb.Append("	[sth_evrakno_sira] ASC,");
            sb.Append("	[sth_satirno] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_06')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_06] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_plasiyer_kodu] ASC,");
            sb.Append("	[sth_tarih] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_07')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_07] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_fat_recid_dbcno] ASC,");
            sb.Append("	[sth_fat_recid_recno] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_08')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_08] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_sip_recid_dbcno] ASC,");
            sb.Append("	[sth_sip_recid_recno] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_10')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_10] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_cari_cinsi] ASC,");
            sb.Append("	[sth_cari_kodu] ASC,");
            sb.Append("	[sth_stok_kod] ASC,");
            sb.Append("	[sth_tarih] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_11')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_11] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_stok_kod] ASC,");
            sb.Append("	[sth_cari_cinsi] ASC,");
            sb.Append("	[sth_cari_kodu] ASC,");
            sb.Append("	[sth_tarih] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_12')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_12] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_exim_kodu] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[S_{0}]') AND name = N'NDX_S_{0}_13')");
            sb.Append(" CREATE NONCLUSTERED INDEX [NDX_S_{0}_13] ON [dbo].[S_{0}] ");
            sb.Append(" (");
            sb.Append("	[sth_isemri_gider_kodu] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(" ; ");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND type in (N'U'))");
            sb.Append(" BEGIN ");
            sb.Append("CREATE TABLE [dbo].[P_{0}](");
            sb.Append("	[prh_RECno] [int] IDENTITY(1,1) NOT NULL,");
            sb.Append("	[prh_RECid_DBCno] [smallint] NOT NULL,");
            sb.Append("	[prh_RECid_RECno] [int] NOT NULL,");
            sb.Append("	[prh_Spec_Rec_no] [int] NULL,");
            sb.Append("	[prh_iptal] [bit] NULL,");
            sb.Append("	[prh_fileid] [smallint] NULL,");
            sb.Append("	[prh_hidden] [bit] NULL,");
            sb.Append("	[prh_kilitli] [bit] NULL,");
            sb.Append("	[prh_degisti] [bit] NULL,");
            sb.Append("	[prh_checksum] [int] NULL,");
            sb.Append("	[prh_create_user] [smallint] NULL,");
            sb.Append("	[prh_create_date] [datetime] NULL,");
            sb.Append("	[prh_lastup_user] [smallint] NULL,");
            sb.Append("	[prh_lastup_date] [datetime] NULL,");
            sb.Append("	[prh_special1] [nvarchar](4) NULL,");
            sb.Append("	[prh_special2] [nvarchar](4) NULL,");
            sb.Append("	[prh_special3] [nvarchar](4) NULL,");
            sb.Append("	[prh_firmano] [int] NULL,");
            sb.Append("	[prh_subeno] [int] NULL,");
            sb.Append("	[prh_promo_kodu] [nvarchar](25) NULL,");
            sb.Append("	[prh_evrak_kaynak] [tinyint] NULL,");
            sb.Append("	[prh_sth_evraktip] [tinyint] NULL,");
            sb.Append("	[prh_evrak_cins] [tinyint] NULL,");
            sb.Append("	[prh_sth_evrakno_seri] [dbo].[nvarchar_evrakseri] NULL,");
            sb.Append("	[prh_sth_evrakno_sira] [int] NULL,");
            sb.Append("	[prh_sth_satirno] [int] NULL,");
            sb.Append("	[prh_urun_cinsi] [tinyint] NULL,");
            sb.Append("	[prh_stok_kodu] [nvarchar](25) NULL,");
            sb.Append("	[prh_cari_kodu] [nvarchar](25) NULL,");
            sb.Append("	[prh_tarih] [datetime] NULL,");
            sb.Append("	[prh_plasiyer_kodu] [nvarchar](25) NULL,");
            sb.Append("	[prh_miktar] [float] NULL,");
            sb.Append("	[prh_tutar] [float] NULL,");
            sb.Append("	[prh_yansiyan_promo_tutari] [float] NULL,");
            sb.Append("	[prh_promosyon_tipi] [smallint] NULL,");
            sb.Append("	[prh_uygulama_tipi] [smallint] NULL,");
            sb.Append(" CONSTRAINT [NDX_P_{0}_00] PRIMARY KEY CLUSTERED ");
            sb.Append("(");
            sb.Append("	[prh_RECno] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(") ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND name = N'NDX_P_{0}_01')");
            sb.Append(" BEGIN ");
            sb.Append("CREATE UNIQUE NONCLUSTERED INDEX [NDX_P_{0}_01] ON [dbo].[P_{0}]");
            sb.Append("(");
            sb.Append("	[prh_RECid_DBCno] ASC,");
            sb.Append("	[prh_RECid_RECno] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND name = N'NDX_P_{0}_02')");
            sb.Append(" BEGIN ");
            sb.Append("CREATE NONCLUSTERED INDEX [NDX_P_{0}_02] ON [dbo].[P_{0}]");
            sb.Append("(");
            sb.Append("	[prh_promo_kodu] ASC,");
            sb.Append("	[prh_tarih] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND name = N'NDX_P_{0}_03')");
            sb.Append(" BEGIN ");
            sb.Append("CREATE NONCLUSTERED INDEX [NDX_P_{0}_03] ON [dbo].[P_{0}]");
            sb.Append("(");
            sb.Append("	[prh_tarih] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND name = N'NDX_P_{0}_04')");
            sb.Append(" BEGIN ");
            sb.Append("CREATE NONCLUSTERED INDEX [NDX_P_{0}_04] ON [dbo].[P_{0}]");
            sb.Append("(");
            sb.Append("	[prh_stok_kodu] ASC,");
            sb.Append("	[prh_promosyon_tipi] ASC,");
            sb.Append("	[prh_tarih] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND name = N'NDX_P_{0}_05')");
            sb.Append(" BEGIN ");
            sb.Append("CREATE NONCLUSTERED INDEX [NDX_P_{0}_05] ON [dbo].[P_{0}]");
            sb.Append("(");
            sb.Append("	[prh_tarih] ASC,");
            sb.Append("	[prh_sth_evraktip] ASC,");
            sb.Append("	[prh_sth_evrakno_seri] ASC,");
            sb.Append("	[prh_sth_evrakno_sira] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");

            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[P_{0}]') AND name = N'NDX_P_{0}_06')");
            sb.Append(" BEGIN ");
            sb.Append("CREATE NONCLUSTERED INDEX [NDX_P_{0}_06] ON [dbo].[P_{0}]");
            sb.Append("(");
            sb.Append("	[prh_cari_kodu] ASC,");
            sb.Append("	[prh_tarih] ASC");
            sb.Append(")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
            sb.Append(" END ");
            sb.Append(";");



            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[O_{0}]') AND type in (N'U'))");
            sb.Append(" BEGIN");
            sb.Append(" CREATE TABLE [dbo].[O_{0}](");
            sb.Append("	[po_RECno] [int] IDENTITY(1,1) NOT NULL,");
            sb.Append(" [po_RECid_DBCno] [smallint] NOT NULL, ");
            sb.Append(" [po_RECid_RECno] [int] NOT NULL, ");
            sb.Append(" [po_SpecRECno] [int] NULL, ");
            sb.Append(" [po_iptal] [bit] NULL, ");
            sb.Append(" [po_fileid] [smallint] NULL, ");
            sb.Append(" [po_hidden] [bit] NULL, ");
            sb.Append(" [po_kilitli] [bit] NULL, ");
            sb.Append(" [po_degisti] [bit] NULL, ");
            sb.Append(" [po_checksum] [int] NULL, ");
            sb.Append(" [po_create_user] [smallint] NULL, ");
            sb.Append(" [po_create_date] [datetime] NULL, ");
            sb.Append(" [po_lastup_user] [smallint] NULL, ");
            sb.Append(" [po_lastup_date] [datetime] NULL, ");
            sb.Append(" [po_special1] [nvarchar](4) NULL, ");
            sb.Append(" [po_special2] [nvarchar](4) NULL, ");
            sb.Append(" [po_special3] [nvarchar](4) NULL, ");
            sb.Append(" [po_firmano] [int] NULL, ");
            sb.Append(" [po_subeno] [int] NULL, ");
            sb.Append(" [po_KasaKodu] [nvarchar](4) NULL, ");
            sb.Append(" [po_BelgeNo] [int] NULL, ");
            sb.Append(" [po_KasiyerKodu] [nvarchar](6) NULL, ");
            sb.Append(" [po_BelgeTarihi] [datetime] NULL, ");
            sb.Append(" [po_BelgeToplam] [float] NULL, ");
            sb.Append(" [po_VerMtrh0] [float] NULL, ");
            sb.Append(" [po_VerMtrh1] [float] NULL, ");
            sb.Append(" [po_VerMtrh2] [float] NULL, ");
            sb.Append(" [po_VerMtrh3] [float] NULL, ");
            sb.Append(" [po_VerMtrh4] [float] NULL, ");
            sb.Append(" [po_VerMtrh5] [float] NULL, ");
            sb.Append(" [po_VerMtrh6] [float] NULL, ");
            sb.Append(" [po_VerMtrh7] [float] NULL, ");
            sb.Append(" [po_VerMtrh8] [float] NULL, ");
            sb.Append(" [po_VerMtrh9] [float] NULL, ");
            sb.Append(" [po_VerMtrh10] [float] NULL, ");
            sb.Append(" [po_Vergi1] [float] NULL, ");
            sb.Append(" [po_Vergi2] [float] NULL, ");
            sb.Append(" [po_Vergi3] [float] NULL, ");
            sb.Append(" [po_Vergi4] [float] NULL, ");
            sb.Append(" [po_Vergi5] [float] NULL, ");
            sb.Append(" [po_Vergi6] [float] NULL, ");
            sb.Append(" [po_Vergi7] [float] NULL, ");
            sb.Append(" [po_Vergi8] [float] NULL, ");
            sb.Append(" [po_Vergi9] [float] NULL, ");
            sb.Append(" [po_Vergi10] [float] NULL, ");
            sb.Append(" [po_Fisfatura] [tinyint] NULL, ");
            sb.Append(" [po_Pozisyon] [tinyint] NULL, ");
            sb.Append(" [po_CariKodu] [nvarchar](25) NULL, ");
            sb.Append(" [po_Yuvarlama] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut1] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut1] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut2] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut2] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut3] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut3] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut4] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut4] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut5] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut5] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut6] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut6] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut7] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut7] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut8] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut8] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut9] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut9] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut10] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut10] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut11] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut11] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut12] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut12] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut13] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut13] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut14] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut14] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut15] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut15] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut16] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut16] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut17] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut17] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut18] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut18] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut19] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut19] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut20] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut20] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut21] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut21] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut22] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut22] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut23] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut23] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut24] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut24] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut25] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut25] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut26] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut26] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut27] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut27] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut28] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut28] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut29] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut29] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut30] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut30] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut31] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut31] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut32] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut32] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut33] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut33] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut34] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut34] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut35] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut35] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut36] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut36] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut37] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut37] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut38] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut38] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut39] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut39] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut40] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut40] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut41] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut41] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut42] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut42] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut43] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut43] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut44] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut44] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut45] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut45] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut46] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut46] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut47] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut47] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut48] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut48] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut49] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut49] [float] NULL, ");
            sb.Append(" [po_Odm_AnaDtut50] [float] NULL, ");
            sb.Append(" [po_Odm_OrjDtut50] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi1] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade1] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar1] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi2] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade2] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar2] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi3] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade3] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar3] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi4] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade4] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar4] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi5] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade5] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar5] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi6] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade6] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar6] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi7] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade7] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar7] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi8] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade8] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar8] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi9] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade9] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar9] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi10] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade10] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar10] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi11] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade11] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar11] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi12] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade12] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar12] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi13] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade13] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar13] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi14] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade14] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar14] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi15] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade15] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar15] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi16] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade16] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar16] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi17] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade17] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar17] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi18] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade18] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar18] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi19] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade19] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar19] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi20] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade20] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar20] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi21] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade21] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar21] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi22] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade22] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar22] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi23] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade23] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar23] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi24] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade24] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar24] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi25] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade25] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar25] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi26] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade26] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar26] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi27] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade27] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar27] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi28] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade28] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar28] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi29] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade29] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar29] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi30] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade30] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar30] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi31] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade31] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar31] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi32] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade32] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar32] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi33] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade33] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar33] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi34] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade34] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar34] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi35] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade35] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar35] [float] NULL, ");
            sb.Append(" [po_Vadeler_OdemeTipi36] [tinyint] NULL, ");
            sb.Append(" [po_Vadeler_vade36] [datetime] NULL, ");
            sb.Append(" [po_Vadeler_Tutar36] [float] NULL, ");
            sb.Append(" [po_Tks_Satis] [bit] NULL, ");
            sb.Append(" [po_Tks_Satis_Tutar] [float] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi1] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi2] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi3] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi4] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi5] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi6] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi7] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi8] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi9] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi10] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi11] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi12] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi13] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi14] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi15] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi16] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi17] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi18] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi19] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi20] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi21] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi22] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi23] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi24] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi25] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi26] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi27] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi28] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi29] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi30] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi31] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi32] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi33] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi34] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi35] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi36] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi37] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi38] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi39] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi40] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi41] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi42] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi43] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi44] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi45] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi46] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi47] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi48] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi49] [tinyint] NULL, ");
            sb.Append(" [po_Odm_TaksitTipi50] [tinyint] NULL, ");
            sb.Append(" [po_OdemeNo1] [tinyint] NULL, ");
            sb.Append(" [po_ProvizyonKodu1] [nvarchar](10) NULL, ");
            sb.Append(" [po_ProvizyonTutari1] [float] NULL, ");
            sb.Append(" [po_OdemeNo2] [tinyint] NULL, ");
            sb.Append(" [po_ProvizyonKodu2] [nvarchar](10) NULL, ");
            sb.Append(" [po_ProvizyonTutari2] [float] NULL, ");
            sb.Append(" [po_OdemeNo3] [tinyint] NULL, ");
            sb.Append(" [po_ProvizyonKodu3] [nvarchar](10) NULL, ");
            sb.Append(" [po_ProvizyonTutari3] [float] NULL, ");
            sb.Append(" [po_OdemeNo4] [tinyint] NULL, ");
            sb.Append(" [po_ProvizyonKodu4] [nvarchar](10) NULL, ");
            sb.Append(" [po_ProvizyonTutari4] [float] NULL, ");
            sb.Append(" [po_OdemeNo5] [tinyint] NULL, ");
            sb.Append(" [po_ProvizyonKodu5] [nvarchar](10) NULL, ");
            sb.Append(" [po_ProvizyonTutari5] [float] NULL, ");
            sb.Append(" [po_OdemeNo6] [tinyint] NULL, ");
            sb.Append(" [po_ProvizyonKodu6] [nvarchar](10) NULL, ");
            sb.Append(" [po_ProvizyonTutari6] [float] NULL, ");
            sb.Append(" [po_Tahsilat_evrakno_seri] [nvarchar](6) NULL, ");
            sb.Append(" [po_Tahsilat_evrakno_sira] [int] NULL, ");
            sb.Append(" [po_Tahsilat_Tutari] [float] NULL, ");
            sb.Append(" [po_ParaUstuOdemeTipi] [tinyint] NULL, ");
            sb.Append(" [po_ParaUstuAnaDtut] [float] NULL, ");
            sb.Append(" [po_ParaUstuOrjDtut] [float] NULL, ");
            sb.Append(" [po_EvrakID] [nvarchar](40) NULL, ");
            sb.Append(" [po_AdresNo] [int] NULL, ");
            sb.Append(" [po_EArsivSeri] [nvarchar](7) NULL, ");
            sb.Append(" [po_EArsivSira] [int] NULL, ");
            sb.Append(" [po_ZNo] [int] NULL, ");
            sb.Append(" [po_FNo] [int] NULL, ");
            sb.Append(" [po_EJNo] [int] NULL, ");
            sb.Append(" CONSTRAINT [NDX_O_{0}_00] PRIMARY KEY CLUSTERED ");
            sb.Append(" (");
            sb.Append("	[po_RECno] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(" ) ON [PRIMARY]");
            sb.Append(" END");

            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[O_{0}]') AND name = N'NDX_O_{0}_01')");
            sb.Append(" CREATE UNIQUE NONCLUSTERED INDEX [NDX_O_{0}_01] ON [dbo].[O_{0}] ");
            sb.Append(" (");
            sb.Append("	[po_RECid_DBCno] ASC,");
            sb.Append("	[po_RECid_RECno] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");
            sb.Append(" IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[O_{0}]') AND name = N'NDX_O_{0}_02')");
            sb.Append(" CREATE UNIQUE NONCLUSTERED INDEX [NDX_O_{0}_02] ON [dbo].[O_{0}] ");
            sb.Append(" (");
            sb.Append("	[po_KasaKodu] ASC,");
            sb.Append("	[po_BelgeNo] ASC");
            sb.Append(" )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]");
            sb.Append(";");

            sb.Append("IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MAGAZA_OZET]') AND type in (N'U'))");
            sb.Append(" BEGIN ");
            sb.Append(" CREATE TABLE [dbo].[MAGAZA_OZET]( ");
            sb.Append(" 	[ID] [int] IDENTITY(1,1) NOT NULL, ");
            sb.Append(" 	[Tarih] [datetime] NOT NULL, ");
            sb.Append(" 	[MagazaNo] [int] NOT NULL, ");
            sb.Append(" 	[SatisBelgeAdedi] [int] NOT NULL, ");
            sb.Append(" 	[SatisTutari] [float] NOT NULL, ");
            sb.Append(" 	[IadeBelgeAdedi] [int] NOT NULL, ");
            sb.Append(" 	[IadeBelgeTutari] [float] NOT NULL, ");
            sb.Append(" 	[NetSatisTutari] [float] NOT NULL, ");
            sb.Append("  CONSTRAINT [PK_MAGAZA_OZET] PRIMARY KEY CLUSTERED  ");
            sb.Append(" ( [Tarih] ASC,	[MagazaNo] ASC ) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY] ");
            sb.Append(" END");

            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand(string.Format(sb.ToString(), tableName), cn))
                {
                    cmd.ExecuteNonQuery();
                }
                cn.Close();
            }
        }

        public void TruncateTable(DateTime tarih)
        {
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            TruncateTable(tarih, tableName);
        }
        public void TruncateTable(DateTime tarih, string tableName)
        {
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand(string.Format("TRUNCATE TABLE O_{0}", tableName), cn))
                {
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = string.Format("TRUNCATE TABLE S_{0}", tableName);
                    cmd.ExecuteNonQuery();
                }
                cn.Close();
            }
        }
        public void StokYukle(DateTime tarih)
        {
            Dictionary<string, string> db = Sessions.Get.DataBase.Stoklar;
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString.Replace("_WORKDATA", "")))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand("SELECT     bar_kodu, bar_stokkodu  FROM BARKOD_TANIMLARI WITH (NOLOCK) WHERE     (bar_lastup_date >= @tarih)", cn))
                {
                    cmd.Parameters.Add("@tarih", System.Data.SqlDbType.DateTime).Value = tarih;
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        if (db.ContainsKey(rd.GetString(0)))
                        {
                            db[rd.GetString(0)] = rd.GetString(1);
                        }
                        else
                        {
                            db.Add(rd.GetString(0), rd.GetString(1));
                        }
                    }
                }
                cn.Close();
            }
        }

        public int SonFisNo(DateTime tarih, int kasaNo)
        {
            int sonuc = 0;
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand(string.Format("SELECT     isnull(MAX(po_BelgeNo),0) FROM  O_{0} WITH (NOLOCK) WHERE     (po_KasaKodu = @kasaNo)", tableName), cn))
                {
                    cmd.CommandTimeout = 9999;
                    cmd.Parameters.Add("@kasaNo", System.Data.SqlDbType.VarChar, 4).Value = "K" + kasaNo.ToString("000");
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        sonuc = rd.GetInt32(0);
                    }
                }
                cn.Close();
            }
            return sonuc;
        }

        public int SonSatirNo(DateTime tarih, int kasaNo)
        {
            int sonuc = 0;
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand(string.Format("SELECT     isnull(MAX(sth_satirno),0) + 1 FROM  S_{0} WITH (NOLOCK) WHERE     (sth_evrakno_seri = @kasaNo)", tableName), cn))
                {
                    cmd.CommandTimeout = 9999;
                    cmd.Parameters.Add("@kasaNo", System.Data.SqlDbType.VarChar, 4).Value = "K" + kasaNo.ToString("000");
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        sonuc = rd.GetInt32(0);
                    }
                }
                cn.Close();
            }
            return sonuc;
        }

        public decimal GunlukCiro(DateTime tarih)
        {
            decimal sonuc = 0;
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand(string.Format("SELECT     CAST(SUM(po_BelgeToplam) AS decimal(16, 2)) FROM  O_{0} WITH (NOLOCK)", tableName), cn))
                {
                    cmd.CommandTimeout = 9999;
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        sonuc = Convert.ToDecimal(rd[0]);
                    }
                }
                cn.Close();
            }
            return sonuc;
        }

        private void StokBul(string barkod)
        {
            Dictionary<string, string> db = Sessions.Get.DataBase.Stoklar;
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString.Replace("_WORKDATA", "")))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand("SELECT bar_stokkodu  FROM BARKOD_TANIMLARI WITH (NOLOCK) WHERE     (bar_kodu = @barkod)", cn))
                {
                    cmd.CommandTimeout = 9999;
                    cmd.Parameters.Add("@barkod", System.Data.SqlDbType.VarChar, 25).Value = barkod;
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        if (db.ContainsKey(barkod))
                        {
                            db[barkod] = rd.GetString(0);
                        }
                        else
                        {
                            db.Add(barkod, rd.GetString(0));
                        }
                    }
                }
                cn.Close();
            }
        }

        public string StokKodu(string barkod)
        {
            Dictionary<string, string> db = Sessions.Get.DataBase.Stoklar;
            string sonuc = "";
            if (db.ContainsKey(barkod))
            {
                sonuc = db[barkod];
            }
            else
            {
                StokBul(barkod);
                if (db.ContainsKey(barkod))
                {
                    sonuc = db[barkod];
                }
                else
                {
                    sonuc = barkod;
                }
            }
            return sonuc;
        }

        public void MagazaCiroGuncelle(DateTime tarih, int belgesayisi, int iadesayisi, decimal satisTutari, decimal iadeTutari)
        {
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand("if exists(SELECT     ID FROM         MAGAZA_OZET WHERE     (Tarih = @tarih) AND (MagazaNo = @magaza)) UPDATE    MAGAZA_OZET SET  SatisBelgeAdedi = @satisMiktar, SatisTutari = @satisTutar, IadeBelgeAdedi = @iadeMiktar, IadeBelgeTutari = @iadeTutar, NetSatisTutari = @netSatis WHERE     (Tarih = @tarih) AND (MagazaNo = @magaza) else INSERT INTO MAGAZA_OZET (SatisBelgeAdedi, SatisTutari, IadeBelgeAdedi, IadeBelgeTutari, NetSatisTutari, Tarih, MagazaNo) VALUES (@satisMiktar,@satisTutar,@iadeMiktar,@iadeTutar,@netSatis,@tarih,@magaza)", cn))
                {
                    cmd.CommandTimeout = 9999;
                    cmd.Parameters.Add("@satisMiktar", System.Data.SqlDbType.Float).Value = belgesayisi;
                    cmd.Parameters.Add("@satisTutar", System.Data.SqlDbType.Float).Value = satisTutari;
                    cmd.Parameters.Add("@iadeMiktar", System.Data.SqlDbType.Float).Value = iadesayisi;
                    cmd.Parameters.Add("@iadeTutar", System.Data.SqlDbType.Float).Value = iadeTutari;
                    cmd.Parameters.Add("@netSatis", System.Data.SqlDbType.Float).Value = satisTutari - iadeTutari;
                    cmd.Parameters.Add("@tarih", System.Data.SqlDbType.DateTime).Value = new DateTime(tarih.Year, tarih.Month, tarih.Day);
                    cmd.Parameters.Add("@magaza", System.Data.SqlDbType.Int).Value = int.Parse(Sessions.Get[Settings.DepoNo].ToString());
                    cmd.ExecuteNonQuery();
                }
                cn.Close();
            }
        }

        public void SatisEkle(DateTime tarih, HareketUst[] lines)
        {
            string tableName = string.Format("{0}{1}{2}_{3}", tarih.Year, tarih.Month.ToString("00"), tarih.Day.ToString("00"), int.Parse(Sessions.Get[Settings.DepoNo].ToString()).ToString("000"));
            SatisEkle(tarih, lines, tableName, Sessions.Get[Settings.MikroKullanici].ToString(), int.Parse(Sessions.Get[Settings.DepoNo].ToString()));
        }

        public void SatisEkle(DateTime tarih, HareketUst[] lines, string tableName, string mikroKullanici, int depoNo)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("if not exists(select po_RECno from O_{0} with (nolock) where po_KasaKodu=@kasaKodu and po_BelgeNo=@belgeNo)", tableName);
            sb.AppendFormat(" INSERT INTO O_{0} ", tableName);
            sb.Append("                      (po_RECid_DBCno, po_RECid_RECno, po_SpecRECno, po_iptal, po_fileid, po_hidden, po_kilitli, po_degisti, po_checksum, po_create_user, po_create_date, po_lastup_user, po_lastup_date, ");
            sb.Append("                      po_special1, po_special2, po_special3, po_KasaKodu, po_BelgeNo, po_BelgeTarihi, po_BelgeToplam, po_VerMtrh0, po_VerMtrh1, po_VerMtrh2, po_VerMtrh3, po_VerMtrh4, po_VerMtrh5, ");
            sb.Append("                      po_VerMtrh6, po_VerMtrh7, po_VerMtrh8, po_VerMtrh9, po_VerMtrh10, po_Vergi1, po_Vergi2, po_Vergi3, po_Vergi4, po_Vergi5, po_Vergi6, po_Vergi7, po_Vergi8, po_Vergi9, po_Vergi10, po_Fisfatura,");
            sb.Append("                       po_Pozisyon, po_CariKodu, po_Yuvarlama, po_Odm_AnaDtut1, po_Odm_OrjDtut1, po_Odm_AnaDtut2, po_Odm_OrjDtut2, po_Odm_AnaDtut3, po_Odm_OrjDtut3, po_Odm_AnaDtut4, ");
            sb.Append("                      po_Odm_OrjDtut4, po_Odm_AnaDtut5, po_Odm_OrjDtut5, po_Odm_AnaDtut6, po_Odm_OrjDtut6, po_Odm_AnaDtut7, po_Odm_OrjDtut7, po_Odm_AnaDtut8, po_Odm_OrjDtut8, po_Odm_AnaDtut9, ");
            sb.Append("                      po_Odm_OrjDtut9, po_Odm_AnaDtut10, po_Odm_OrjDtut10, po_Odm_AnaDtut11, po_Odm_OrjDtut11, po_Odm_AnaDtut12, po_Odm_OrjDtut12, po_Odm_AnaDtut13, po_Odm_OrjDtut13, ");
            sb.Append("                      po_Odm_AnaDtut14, po_Odm_OrjDtut14, po_Odm_AnaDtut15, po_Odm_OrjDtut15, po_Odm_AnaDtut16, po_Odm_OrjDtut16, po_Odm_AnaDtut17, po_Odm_OrjDtut17, po_Odm_AnaDtut18, ");
            sb.Append("                      po_Odm_OrjDtut18, po_Odm_AnaDtut19, po_Odm_OrjDtut19, po_Odm_AnaDtut20, po_Odm_OrjDtut20, po_Odm_AnaDtut21, po_Odm_OrjDtut21, po_Odm_AnaDtut22, po_Odm_OrjDtut22, ");
            sb.Append("                      po_Odm_AnaDtut23, po_Odm_OrjDtut23, po_Odm_AnaDtut24, po_Odm_OrjDtut24, po_Odm_AnaDtut25, po_Odm_OrjDtut25, po_Odm_AnaDtut26, po_Odm_OrjDtut26, po_Odm_AnaDtut27, ");
            sb.Append("                      po_Odm_OrjDtut27, po_Odm_AnaDtut28, po_Odm_OrjDtut28, po_Odm_AnaDtut29, po_Odm_OrjDtut29, po_Odm_AnaDtut30, po_Odm_OrjDtut30, po_Odm_AnaDtut31, po_Odm_OrjDtut31, ");
            sb.Append("                      po_Odm_AnaDtut32, po_Odm_OrjDtut32, po_Odm_AnaDtut33, po_Odm_OrjDtut33, po_Odm_AnaDtut34, po_Odm_OrjDtut34, po_Odm_AnaDtut35, po_Odm_OrjDtut35, po_Odm_AnaDtut36, ");
            sb.Append("                      po_Odm_OrjDtut36, po_Odm_AnaDtut37, po_Odm_OrjDtut37, po_Odm_AnaDtut38, po_Odm_OrjDtut38, po_Odm_AnaDtut39, po_Odm_OrjDtut39, po_Odm_AnaDtut40, po_Odm_OrjDtut40, ");
            sb.Append("                      po_Odm_AnaDtut41, po_Odm_OrjDtut41, po_Odm_AnaDtut42, po_Odm_OrjDtut42, po_Odm_AnaDtut43, po_Odm_OrjDtut43, po_Odm_AnaDtut44, po_Odm_OrjDtut44, po_Odm_AnaDtut45, ");
            sb.Append("                      po_Odm_OrjDtut45, po_Odm_AnaDtut46, po_Odm_OrjDtut46, po_Odm_AnaDtut47, po_Odm_OrjDtut47, po_Odm_AnaDtut48, po_Odm_OrjDtut48, po_Odm_AnaDtut49, po_Odm_OrjDtut49, ");
            sb.Append("                      po_Odm_AnaDtut50, po_Odm_OrjDtut50, po_Vadeler_OdemeTipi1, po_Vadeler_vade1, po_Vadeler_Tutar1, po_Vadeler_OdemeTipi2, po_Vadeler_vade2, po_Vadeler_Tutar2, ");
            sb.Append("                      po_Vadeler_OdemeTipi3, po_Vadeler_vade3, po_Vadeler_Tutar3, po_Vadeler_OdemeTipi4, po_Vadeler_vade4, po_Vadeler_Tutar4, po_Vadeler_OdemeTipi5, po_Vadeler_vade5, po_Vadeler_Tutar5, ");
            sb.Append("                      po_Vadeler_OdemeTipi6, po_Vadeler_vade6, po_Vadeler_Tutar6, po_Vadeler_OdemeTipi7, po_Vadeler_vade7, po_Vadeler_Tutar7, po_Vadeler_OdemeTipi8, po_Vadeler_vade8, po_Vadeler_Tutar8, ");
            sb.Append("                      po_Vadeler_OdemeTipi9, po_Vadeler_vade9, po_Vadeler_Tutar9, po_Vadeler_OdemeTipi10, po_Vadeler_vade10, po_Vadeler_Tutar10, po_Vadeler_OdemeTipi11, po_Vadeler_vade11, ");
            sb.Append("                      po_Vadeler_Tutar11, po_Vadeler_OdemeTipi12, po_Vadeler_vade12, po_Vadeler_Tutar12, po_Vadeler_OdemeTipi13, po_Vadeler_vade13, po_Vadeler_Tutar13, po_Vadeler_OdemeTipi14, ");
            sb.Append("                      po_Vadeler_vade14, po_Vadeler_Tutar14, po_Vadeler_OdemeTipi15, po_Vadeler_vade15, po_Vadeler_Tutar15, po_Vadeler_OdemeTipi16, po_Vadeler_vade16, po_Vadeler_Tutar16, ");
            sb.Append("                      po_Vadeler_OdemeTipi17, po_Vadeler_vade17, po_Vadeler_Tutar17, po_Vadeler_OdemeTipi18, po_Vadeler_vade18, po_Vadeler_Tutar18, po_Vadeler_OdemeTipi19, po_Vadeler_vade19, ");
            sb.Append("                      po_Vadeler_Tutar19, po_Vadeler_OdemeTipi20, po_Vadeler_vade20, po_Vadeler_Tutar20, po_Vadeler_OdemeTipi21, po_Vadeler_vade21, po_Vadeler_Tutar21, po_Vadeler_OdemeTipi22, ");
            sb.Append("                      po_Vadeler_vade22, po_Vadeler_Tutar22, po_Vadeler_OdemeTipi23, po_Vadeler_vade23, po_Vadeler_Tutar23, po_Vadeler_OdemeTipi24, po_Vadeler_vade24, po_Vadeler_Tutar24, ");
            sb.Append("                      po_Vadeler_OdemeTipi25, po_Vadeler_vade25, po_Vadeler_Tutar25, po_Vadeler_OdemeTipi26, po_Vadeler_vade26, po_Vadeler_Tutar26, po_Vadeler_OdemeTipi27, po_Vadeler_vade27, ");
            sb.Append("                      po_Vadeler_Tutar27, po_Vadeler_OdemeTipi28, po_Vadeler_vade28, po_Vadeler_Tutar28, po_Vadeler_OdemeTipi29, po_Vadeler_vade29, po_Vadeler_Tutar29, po_Vadeler_OdemeTipi30, ");
            sb.Append("                      po_Vadeler_vade30, po_Vadeler_Tutar30, po_Vadeler_OdemeTipi31, po_Vadeler_vade31, po_Vadeler_Tutar31, po_Vadeler_OdemeTipi32, po_Vadeler_vade32, po_Vadeler_Tutar32, ");
            sb.Append("                      po_Vadeler_OdemeTipi33, po_Vadeler_vade33, po_Vadeler_Tutar33, po_Vadeler_OdemeTipi34, po_Vadeler_vade34, po_Vadeler_Tutar34, po_Vadeler_OdemeTipi35, po_Vadeler_vade35, ");
            sb.Append("                      po_Vadeler_Tutar35, po_Vadeler_OdemeTipi36, po_Vadeler_vade36, po_Vadeler_Tutar36, po_Tks_Satis, po_Tks_Satis_Tutar, po_Odm_TaksitTipi1, po_Odm_TaksitTipi2, po_Odm_TaksitTipi3, ");
            sb.Append("                      po_Odm_TaksitTipi4, po_Odm_TaksitTipi5, po_Odm_TaksitTipi6, po_Odm_TaksitTipi7, po_Odm_TaksitTipi8, po_Odm_TaksitTipi9, po_Odm_TaksitTipi10, po_Odm_TaksitTipi11, ");
            sb.Append("                      po_Odm_TaksitTipi12, po_Odm_TaksitTipi13, po_Odm_TaksitTipi14, po_Odm_TaksitTipi15, po_Odm_TaksitTipi16, po_Odm_TaksitTipi17, po_Odm_TaksitTipi18, po_Odm_TaksitTipi19, ");
            sb.Append("                      po_Odm_TaksitTipi20, po_Odm_TaksitTipi21, po_Odm_TaksitTipi22, po_Odm_TaksitTipi23, po_Odm_TaksitTipi24, po_Odm_TaksitTipi25, po_Odm_TaksitTipi26, po_Odm_TaksitTipi27, ");
            sb.Append("                      po_Odm_TaksitTipi28, po_Odm_TaksitTipi29, po_Odm_TaksitTipi30, po_Odm_TaksitTipi31, po_Odm_TaksitTipi32, po_Odm_TaksitTipi33, po_Odm_TaksitTipi34, po_Odm_TaksitTipi35, ");
            sb.Append("                      po_Odm_TaksitTipi36, po_Odm_TaksitTipi37, po_Odm_TaksitTipi38, po_Odm_TaksitTipi39, po_Odm_TaksitTipi40, po_Odm_TaksitTipi41, po_Odm_TaksitTipi42, po_Odm_TaksitTipi43, ");
            sb.Append("                      po_Odm_TaksitTipi44, po_Odm_TaksitTipi45, po_Odm_TaksitTipi46, po_Odm_TaksitTipi47, po_Odm_TaksitTipi48, po_Odm_TaksitTipi49, po_Odm_TaksitTipi50, po_OdemeNo1, ");
            sb.Append("                      po_ProvizyonKodu1, po_ProvizyonTutari1, po_OdemeNo2, po_ProvizyonKodu2, po_ProvizyonTutari2, po_OdemeNo3, po_ProvizyonKodu3, po_ProvizyonTutari3, po_OdemeNo4, ");
            sb.Append("                      po_ProvizyonKodu4, po_ProvizyonTutari4, po_OdemeNo5, po_ProvizyonKodu5, po_ProvizyonTutari5, po_OdemeNo6, po_ProvizyonKodu6, po_ProvizyonTutari6, po_Tahsilat_evrakno_sira, ");
            sb.Append("                      po_Tahsilat_Tutari,po_Tahsilat_evrakno_seri,po_EvrakID,po_AdresNo,po_EArsivSeri,po_EArsivSira,po_ZNo,po_FNo,po_EJNo)");
            sb.Append(" VALUES     (0, -1, 0, 0, 1003, 0, 0, 0, 0,@user,@createDate,@user,@updateDate, '', '', ");
            sb.Append("                      '',@kasaKodu,@belgeNo,@belgeTarihi,@belgeToplam,@matrah0,@matrah1,@matrah2,@matrah3,@matrah4,@matrah5,@matrah6,@matrah7,@matrah8,@matrah9,@matrah10,@kdvTutari1,@kdvTutari2,@kdvTutari3,@kdvTutari4,@kdvTutari5,@kdvTutari6,@kdvTutari7,@kdvTutari8,@kdvTutari9,@kdvTutari10,@fisFatura,");
            sb.Append("                       1,@cariKodu, 0,@odeme1,@odeme1,@odeme2,@odeme2,@odeme3,@odeme3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ");
            sb.Append("                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, ");
            sb.Append("                      '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, ");
            sb.Append("                      '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, ");
            sb.Append("                      '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, '18991230', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ");
            sb.Append("                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, 0,'','',0,'',0,0,0,0)");
            sb.Append(" else ");
            sb.AppendFormat(" UPDATE    O_{0}", tableName);
            sb.Append(" SET              po_RECid_DBCno = 0, po_SpecRECno = 0, po_iptal = 0, po_fileid = 1003, po_hidden = 0, po_kilitli = 0, po_degisti = 0, po_checksum = 0, po_create_user = @user, ");
            sb.Append("                      po_create_date = @createDate, po_lastup_user = @user, po_lastup_date = @updateDate, po_special1 = '', po_special2 = '', po_special3 = '', po_BelgeTarihi = @belgeTarihi, ");
            sb.Append("                      po_BelgeToplam = @belgeToplam, po_VerMtrh0 = @matrah0, po_VerMtrh1 = @matrah1, po_VerMtrh2 = @matrah2, po_VerMtrh3 = @matrah3, po_VerMtrh4 = @matrah4, po_VerMtrh5 = @matrah5, ");
            sb.Append("                      po_VerMtrh6 = @matrah6, po_VerMtrh7 = @matrah7, po_VerMtrh8 = @matrah8, po_VerMtrh9 = @matrah9, po_VerMtrh10 = @matrah10, po_Vergi1 = @kdvTutari1, po_Vergi2 = @kdvTutari2, ");
            sb.Append("                      po_Vergi3 = @kdvTutari3, po_Vergi4 = @kdvTutari4, po_Vergi5 = @kdvTutari5, po_Vergi6 = @kdvTutari6, po_Vergi7 = @kdvTutari7, po_Vergi8 = @kdvTutari8, po_Vergi9 = @kdvTutari9, ");
            sb.Append("                      po_Vergi10 = @kdvTutari10, po_Fisfatura = @fisFatura, po_Pozisyon = 1, po_CariKodu = @cariKodu, po_Yuvarlama = 0, po_Odm_AnaDtut1 = @odeme1, po_Odm_OrjDtut1 = @odeme1, ");
            sb.Append("                      po_Odm_AnaDtut2 = @odeme2, po_Odm_OrjDtut2 = @odeme2, po_Odm_AnaDtut3 = @odeme3, po_Odm_OrjDtut3 = @odeme3, po_Odm_AnaDtut4 = 0, po_Odm_OrjDtut4 = 0, po_Odm_AnaDtut5 = 0, ");
            sb.Append("                      po_Odm_OrjDtut5 = 0, po_Odm_AnaDtut6 = 0, po_Odm_OrjDtut6 = 0, po_Odm_AnaDtut7 = 0, po_Odm_OrjDtut7 = 0, po_Odm_AnaDtut8 = 0, po_Odm_OrjDtut8 = 0, po_Odm_AnaDtut9 = 0, ");
            sb.Append("                      po_Odm_OrjDtut9 = 0, po_Odm_AnaDtut10 = 0, po_Odm_OrjDtut10 = 0, po_Odm_AnaDtut11 = 0, po_Odm_OrjDtut11 = 0, po_Odm_AnaDtut12 = 0, po_Odm_OrjDtut12 = 0, po_Odm_AnaDtut13 = 0, ");
            sb.Append("                      po_Odm_OrjDtut13 = 0, po_Odm_AnaDtut14 = 0, po_Odm_OrjDtut14 = 0, po_Odm_AnaDtut15 = 0, po_Odm_OrjDtut15 = 0, po_Odm_AnaDtut16 = 0, po_Odm_OrjDtut16 = 0, po_Odm_AnaDtut17 = 0, ");
            sb.Append("                      po_Odm_OrjDtut17 = 0, po_Odm_AnaDtut18 = 0, po_Odm_OrjDtut18 = 0, po_Odm_AnaDtut19 = 0, po_Odm_OrjDtut19 = 0, po_Odm_AnaDtut20 = 0, po_Odm_OrjDtut20 = 0, po_Odm_AnaDtut21 = 0, ");
            sb.Append("                      po_Odm_OrjDtut21 = 0, po_Odm_AnaDtut22 = 0, po_Odm_OrjDtut22 = 0, po_Odm_AnaDtut23 = 0, po_Odm_OrjDtut23 = 0, po_Odm_AnaDtut24 = 0, po_Odm_OrjDtut24 = 0, po_Odm_AnaDtut25 = 0, ");
            sb.Append("                      po_Odm_OrjDtut25 = 0, po_Odm_AnaDtut26 = 0, po_Odm_OrjDtut26 = 0, po_Odm_AnaDtut27 = 0, po_Odm_OrjDtut27 = 0, po_Odm_AnaDtut28 = 0, po_Odm_OrjDtut28 = 0, po_Odm_AnaDtut29 = 0, ");
            sb.Append("                      po_Odm_OrjDtut29 = 0, po_Odm_AnaDtut30 = 0, po_Odm_OrjDtut30 = 0, po_Odm_AnaDtut31 = 0, po_Odm_OrjDtut31 = 0, po_Odm_AnaDtut32 = 0, po_Odm_OrjDtut32 = 0, po_Odm_AnaDtut33 = 0, ");
            sb.Append("                      po_Odm_OrjDtut33 = 0, po_Odm_AnaDtut34 = 0, po_Odm_OrjDtut34 = 0, po_Odm_AnaDtut35 = 0, po_Odm_OrjDtut35 = 0, po_Odm_AnaDtut36 = 0, po_Odm_OrjDtut36 = 0, po_Odm_AnaDtut37 = 0, ");
            sb.Append("                      po_Odm_OrjDtut37 = 0, po_Odm_AnaDtut38 = 0, po_Odm_OrjDtut38 = 0, po_Odm_AnaDtut39 = 0, po_Odm_OrjDtut39 = 0, po_Odm_AnaDtut40 = 0, po_Odm_OrjDtut40 = 0, po_Odm_AnaDtut41 = 0, ");
            sb.Append("                      po_Odm_OrjDtut41 = 0, po_Odm_AnaDtut42 = 0, po_Odm_OrjDtut42 = 0, po_Odm_AnaDtut43 = 0, po_Odm_OrjDtut43 = 0, po_Odm_AnaDtut44 = 0, po_Odm_OrjDtut44 = 0, po_Odm_AnaDtut45 = 0, ");
            sb.Append("                      po_Odm_OrjDtut45 = 0, po_Odm_AnaDtut46 = 0, po_Odm_OrjDtut46 = 0, po_Odm_AnaDtut47 = 0, po_Odm_OrjDtut47 = 0, po_Odm_AnaDtut48 = 0, po_Odm_OrjDtut48 = 0, po_Odm_AnaDtut49 = 0, ");
            sb.Append("                      po_Odm_OrjDtut49 = 0, po_Odm_AnaDtut50 = 0, po_Odm_OrjDtut50 = 0, po_Vadeler_OdemeTipi1 = 0, po_Vadeler_vade1 = '18991230', po_Vadeler_Tutar1 = 0, po_Vadeler_OdemeTipi2 = 0, ");
            sb.Append("                      po_Vadeler_vade2 = '18991230', po_Vadeler_Tutar2 = 0, po_Vadeler_OdemeTipi3 = 0, po_Vadeler_vade3 = '18991230', po_Vadeler_Tutar3 = 0, po_Vadeler_OdemeTipi4 = 0, ");
            sb.Append("                      po_Vadeler_vade4 = '18991230', po_Vadeler_Tutar4 = 0, po_Vadeler_OdemeTipi5 = 0, po_Vadeler_vade5 = '18991230', po_Vadeler_Tutar5 = 0, po_Vadeler_OdemeTipi6 = 0, ");
            sb.Append("                      po_Vadeler_vade6 = '18991230', po_Vadeler_Tutar6 = 0, po_Vadeler_OdemeTipi7 = 0, po_Vadeler_vade7 = '18991230', po_Vadeler_Tutar7 = 0, po_Vadeler_OdemeTipi8 = 0, ");
            sb.Append("                      po_Vadeler_vade8 = '18991230', po_Vadeler_Tutar8 = 0, po_Vadeler_OdemeTipi9 = 0, po_Vadeler_vade9 = '18991230', po_Vadeler_Tutar9 = 0, po_Vadeler_OdemeTipi10 = 0, ");
            sb.Append("                      po_Vadeler_vade10 = '18991230', po_Vadeler_Tutar10 = 0, po_Vadeler_OdemeTipi11 = 0, po_Vadeler_vade11 = '18991230', po_Vadeler_Tutar11 = 0, po_Vadeler_OdemeTipi12 = 0, ");
            sb.Append("                      po_Vadeler_vade12 = '18991230', po_Vadeler_Tutar12 = 0, po_Vadeler_OdemeTipi13 = 0, po_Vadeler_vade13 = '18991230', po_Vadeler_Tutar13 = 0, po_Vadeler_OdemeTipi14 = 0, ");
            sb.Append("                      po_Vadeler_vade14 = '18991230', po_Vadeler_Tutar14 = 0, po_Vadeler_OdemeTipi15 = 0, po_Vadeler_vade15 = '18991230', po_Vadeler_Tutar15 = 0, po_Vadeler_OdemeTipi16 = 0, ");
            sb.Append("                      po_Vadeler_vade16 = '18991230', po_Vadeler_Tutar16 = 0, po_Vadeler_OdemeTipi17 = 0, po_Vadeler_vade17 = '18991230', po_Vadeler_Tutar17 = 0, po_Vadeler_OdemeTipi18 = 0, ");
            sb.Append("                      po_Vadeler_vade18 = '18991230', po_Vadeler_Tutar18 = 0, po_Vadeler_OdemeTipi19 = 0, po_Vadeler_vade19 = '18991230', po_Vadeler_Tutar19 = 0, po_Vadeler_OdemeTipi20 = 0, ");
            sb.Append("                      po_Vadeler_vade20 = '18991230', po_Vadeler_Tutar20 = 0, po_Vadeler_OdemeTipi21 = 0, po_Vadeler_vade21 = '18991230', po_Vadeler_Tutar21 = 0, po_Vadeler_OdemeTipi22 = 0, ");
            sb.Append("                      po_Vadeler_vade22 = '18991230', po_Vadeler_Tutar22 = 0, po_Vadeler_OdemeTipi23 = 0, po_Vadeler_vade23 = '18991230', po_Vadeler_Tutar23 = 0, po_Vadeler_OdemeTipi24 = 0, ");
            sb.Append("                      po_Vadeler_vade24 = '18991230', po_Vadeler_Tutar24 = 0, po_Vadeler_OdemeTipi25 = 0, po_Vadeler_vade25 = '18991230', po_Vadeler_Tutar25 = 0, po_Vadeler_OdemeTipi26 = 0, ");
            sb.Append("                      po_Vadeler_vade26 = '18991230', po_Vadeler_Tutar26 = 0, po_Vadeler_OdemeTipi27 = 0, po_Vadeler_vade27 = '18991230', po_Vadeler_Tutar27 = 0, po_Vadeler_OdemeTipi28 = 0, ");
            sb.Append("                      po_Vadeler_vade28 = '18991230', po_Vadeler_Tutar28 = 0, po_Vadeler_OdemeTipi29 = 0, po_Vadeler_vade29 = '18991230', po_Vadeler_Tutar29 = 0, po_Vadeler_OdemeTipi30 = 0, ");
            sb.Append("                      po_Vadeler_vade30 = '18991230', po_Vadeler_Tutar30 = 0, po_Vadeler_OdemeTipi31 = 0, po_Vadeler_vade31 = '18991230', po_Vadeler_Tutar31 = 0, po_Vadeler_OdemeTipi32 = 0, ");
            sb.Append("                      po_Vadeler_vade32 = '18991230', po_Vadeler_Tutar32 = 0, po_Vadeler_OdemeTipi33 = 0, po_Vadeler_vade33 = '18991230', po_Vadeler_Tutar33 = 0, po_Vadeler_OdemeTipi34 = 0, ");
            sb.Append("                      po_Vadeler_vade34 = '18991230', po_Vadeler_Tutar34 = 0, po_Vadeler_OdemeTipi35 = 0, po_Vadeler_vade35 = '18991230', po_Vadeler_Tutar35 = 0, po_Vadeler_OdemeTipi36 = 0, ");
            sb.Append("                      po_Vadeler_vade36 = '18991230', po_Vadeler_Tutar36 = 0, po_Tks_Satis = 0, po_Tks_Satis_Tutar = 0, po_Odm_TaksitTipi1 = 0, po_Odm_TaksitTipi2 = 0, po_Odm_TaksitTipi3 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi4 = 0, po_Odm_TaksitTipi5 = 0, po_Odm_TaksitTipi6 = 0, po_Odm_TaksitTipi7 = 0, po_Odm_TaksitTipi8 = 0, po_Odm_TaksitTipi9 = 0, po_Odm_TaksitTipi10 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi11 = 0, po_Odm_TaksitTipi12 = 0, po_Odm_TaksitTipi13 = 0, po_Odm_TaksitTipi14 = 0, po_Odm_TaksitTipi15 = 0, po_Odm_TaksitTipi16 = 0, po_Odm_TaksitTipi17 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi18 = 0, po_Odm_TaksitTipi19 = 0, po_Odm_TaksitTipi20 = 0, po_Odm_TaksitTipi21 = 0, po_Odm_TaksitTipi22 = 0, po_Odm_TaksitTipi23 = 0, po_Odm_TaksitTipi24 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi25 = 0, po_Odm_TaksitTipi26 = 0, po_Odm_TaksitTipi27 = 0, po_Odm_TaksitTipi28 = 0, po_Odm_TaksitTipi29 = 0, po_Odm_TaksitTipi30 = 0, po_Odm_TaksitTipi31 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi32 = 0, po_Odm_TaksitTipi33 = 0, po_Odm_TaksitTipi34 = 0, po_Odm_TaksitTipi35 = 0, po_Odm_TaksitTipi36 = 0, po_Odm_TaksitTipi37 = 0, po_Odm_TaksitTipi38 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi39 = 0, po_Odm_TaksitTipi40 = 0, po_Odm_TaksitTipi41 = 0, po_Odm_TaksitTipi42 = 0, po_Odm_TaksitTipi43 = 0, po_Odm_TaksitTipi44 = 0, po_Odm_TaksitTipi45 = 0, ");
            sb.Append("                      po_Odm_TaksitTipi46 = 0, po_Odm_TaksitTipi47 = 0, po_Odm_TaksitTipi48 = 0, po_Odm_TaksitTipi49 = 0, po_Odm_TaksitTipi50 = 0, po_OdemeNo1 = 0, po_ProvizyonKodu1 = '', ");
            sb.Append("                      po_ProvizyonTutari1 = 0, po_OdemeNo2 = 0, po_ProvizyonKodu2 = '', po_ProvizyonTutari2 = 0, po_OdemeNo3 = 0, po_ProvizyonKodu3 = '', po_ProvizyonTutari3 = 0, po_OdemeNo4 = 0, ");
            sb.Append("                      po_ProvizyonKodu4 = '', po_ProvizyonTutari4 = 0, po_OdemeNo5 = 0, po_ProvizyonKodu5 = '', po_ProvizyonTutari5 = 0, po_OdemeNo6 = 0, po_ProvizyonKodu6 = '', po_ProvizyonTutari6 = 0, ");
            sb.Append("                      po_Tahsilat_evrakno_sira = 0, po_Tahsilat_Tutari = 0,po_Tahsilat_evrakno_seri=''");
            sb.Append(" WHERE     (po_KasaKodu = @kasaKodu) AND (po_BelgeNo = @belgeNo)");
            sb.AppendFormat(";update O_{0} set po_RECid_RECno=po_RECno where po_RECid_RECno=-1 ", tableName);

            using (SqlConnection cn = new SqlConnection(Sessions.Get.CnnString))
            {
                cn.Open();
                //SqlTransaction trn = cn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
                using (SqlCommand cmd = new SqlCommand(sb.ToString(), cn))
                {
                    cmd.CommandTimeout = 9999;
                    //cmd.Transaction = trn;
                    cmd.Parameters.Add("@user", System.Data.SqlDbType.SmallInt);
                    cmd.Parameters.Add("@createDate", System.Data.SqlDbType.DateTime);
                    cmd.Parameters.Add("@updateDate", System.Data.SqlDbType.DateTime);
                    cmd.Parameters.Add("@belgeTarihi", System.Data.SqlDbType.DateTime);
                    cmd.Parameters.Add("@belgeToplam", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah0", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah1", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah2", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah3", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah4", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah5", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah6", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah7", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah8", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah9", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@matrah10", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari1", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari2", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari3", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari4", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari5", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari6", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari7", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari8", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari9", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kdvTutari10", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@fisFatura", System.Data.SqlDbType.TinyInt);
                    cmd.Parameters.Add("@cariKodu", System.Data.SqlDbType.VarChar, 25);
                    cmd.Parameters.Add("@odeme1", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@odeme2", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@odeme3", System.Data.SqlDbType.Float);
                    cmd.Parameters.Add("@kasaKodu", System.Data.SqlDbType.VarChar, 4);
                    cmd.Parameters.Add("@belgeNo", System.Data.SqlDbType.Int);

                    foreach (HareketUst ust in lines)
                    {
                        cmd.Parameters["@user"].Value = mikroKullanici;
                        cmd.Parameters["@createDate"].Value = DateTime.Now;
                        cmd.Parameters["@updateDate"].Value = DateTime.Now;
                        cmd.Parameters["@belgeTarihi"].Value = ust.Tarih;
                        cmd.Parameters["@belgeToplam"].Value = ust.Tutar;
                        cmd.Parameters["@matrah0"].Value = ust.KdvMatrahlari[0];
                        cmd.Parameters["@matrah1"].Value = ust.KdvMatrahlari[1];
                        cmd.Parameters["@matrah2"].Value = ust.KdvMatrahlari[2];
                        cmd.Parameters["@matrah3"].Value = ust.KdvMatrahlari[3];
                        cmd.Parameters["@matrah4"].Value = ust.KdvMatrahlari[4];
                        cmd.Parameters["@matrah5"].Value = ust.KdvMatrahlari[5];
                        cmd.Parameters["@matrah6"].Value = ust.KdvMatrahlari[6];
                        cmd.Parameters["@matrah7"].Value = ust.KdvMatrahlari[7];
                        cmd.Parameters["@matrah8"].Value = ust.KdvMatrahlari[8];
                        cmd.Parameters["@matrah9"].Value = ust.KdvMatrahlari[9];
                        cmd.Parameters["@matrah10"].Value = 0;
                        cmd.Parameters["@kdvTutari1"].Value = ust.KdvTutarlari[0];
                        cmd.Parameters["@kdvTutari2"].Value = ust.KdvTutarlari[1];
                        cmd.Parameters["@kdvTutari3"].Value = ust.KdvTutarlari[2];
                        cmd.Parameters["@kdvTutari4"].Value = ust.KdvTutarlari[3];
                        cmd.Parameters["@kdvTutari5"].Value = ust.KdvTutarlari[4];
                        cmd.Parameters["@kdvTutari6"].Value = ust.KdvTutarlari[5];
                        cmd.Parameters["@kdvTutari7"].Value = ust.KdvTutarlari[6];
                        cmd.Parameters["@kdvTutari8"].Value = ust.KdvTutarlari[7];
                        cmd.Parameters["@kdvTutari9"].Value = ust.KdvTutarlari[8];
                        cmd.Parameters["@kdvTutari10"].Value = ust.KdvTutarlari[9];
                        cmd.Parameters["@cariKodu"].Value = ust.CariKodu;
                        cmd.Parameters["@odeme1"].Value = ust.NakitOdeme;
                        cmd.Parameters["@odeme2"].Value = ust.KrediKartiOdeme;
                        cmd.Parameters["@odeme3"].Value = 0;

                        if (ust.BelgeTipi == 2)
                        {
                            ust.Seri = "I" + ust.KasaSiraNo.ToString("000");
                            cmd.Parameters["@fisFatura"].Value = 0;
                        }
                        else
                        {
                            ust.Seri = "K" + ust.KasaSiraNo.ToString("000");
                            cmd.Parameters["@fisFatura"].Value = 1;
                        }

                        cmd.Parameters["@kasaKodu"].Value = ust.Seri;
                        cmd.Parameters["@belgeNo"].Value = ust.FisNo;
                        cmd.ExecuteNonQuery();

                        HareketDetayEkle(ust, cn, tableName, ust.Seri, ust.FisNo, mikroKullanici, depoNo);
                    }
                }
                try
                {
                    //trn.Commit();
                }
                catch (Exception)
                {
                    //if (trn != null)
                    //    trn.Rollback();
                }
                finally
                {
                    cn.Close();
                }
            }
        }

        private void HareketDetayEkle(HareketUst line, SqlConnection trn, string tableName, string evrakSeri, int evrakSira, string mikroKullanici, int depoNo)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("if not exists(select sth_RECid_RECno from S_{0} with (nolock) where sth_evrakno_seri=@evrakSeri and sth_evrakno_sira=@evrakSira and sth_satirno=@evrakSatir) ", tableName);
            sb.AppendFormat(" INSERT INTO S_{0} ", tableName);
            sb.Append("                          (sth_RECid_DBCno, sth_RECid_RECno, sth_SpecRECno, sth_iptal, sth_fileid, sth_hidden, sth_kilitli, sth_degisti, sth_checksum, sth_create_user, sth_create_date, sth_lastup_user, sth_lastup_date, sth_special1,  ");
            sb.Append("                          sth_special2, sth_special3, sth_firmano, sth_subeno, sth_tarih, sth_tip, sth_cins, sth_normal_iade, sth_evraktip, sth_evrakno_seri, sth_evrakno_sira, sth_satirno, sth_belge_no, sth_belge_tarih, sth_stok_kod,  ");
            sb.Append("                          sth_isk_mas1, sth_isk_mas2, sth_isk_mas3, sth_isk_mas4, sth_isk_mas5, sth_isk_mas6, sth_isk_mas7, sth_isk_mas8, sth_isk_mas9, sth_isk_mas10, sth_sat_iskmas1, sth_sat_iskmas2, sth_sat_iskmas3,  ");
            sb.Append("                          sth_sat_iskmas4, sth_sat_iskmas5, sth_sat_iskmas6, sth_sat_iskmas7, sth_sat_iskmas8, sth_sat_iskmas9, sth_sat_iskmas10, sth_pos_satis, sth_cari_cinsi, sth_cari_kodu, sth_cari_grup_no,  ");
            sb.Append("                          sth_isemri_gider_kodu, sth_plasiyer_kodu, sth_har_doviz_cinsi, sth_har_doviz_kuru, sth_alt_doviz_kuru, sth_stok_doviz_cinsi, sth_stok_doviz_kuru, sth_miktar, sth_miktar2, sth_birim_pntr, sth_tutar,  ");
            sb.Append("                          sth_iskonto1, sth_iskonto2, sth_iskonto3, sth_iskonto4, sth_iskonto5, sth_iskonto6, sth_masraf1, sth_masraf2, sth_masraf3, sth_masraf4, sth_vergi_pntr, sth_vergi, sth_masraf_vergi_pntr, sth_masraf_vergi,  ");
            sb.Append("                          sth_netagirlik, sth_odeme_op, sth_aciklama, sth_sip_recid_dbcno, sth_sip_recid_recno, sth_fat_recid_dbcno, sth_fat_recid_recno, sth_giris_depo_no, sth_cikis_depo_no, sth_malkbl_sevk_tarihi,  ");
            sb.Append("                          sth_cari_srm_merkezi, sth_stok_srm_merkezi, sth_fis_tarihi, sth_fis_sirano, sth_vergisiz_fl, sth_maliyet_ana, sth_maliyet_alternatif, sth_maliyet_orjinal, sth_adres_no, sth_parti_kodu, sth_lot_no,  ");
            sb.Append("                          sth_kons_recid_dbcno, sth_kons_recid_recno, sth_proje_kodu, sth_exim_kodu, sth_otv_pntr, sth_otv_vergi, sth_brutagirlik, sth_disticaret_turu, sth_otvtutari, sth_otvvergisiz_fl, sth_oiv_pntr, sth_oiv_vergi,  ");
            sb.Append("                          sth_oivvergisiz_fl, sth_fiyat_liste_no, sth_promosyon_fl, sth_oivtutari, sth_Tevkifat_turu, sth_nakliyedeposu, sth_nakliyedurumu, sth_yetkili_recid_dbcno, sth_yetkili_recid_recno, sth_taxfree_fl,sth_ilave_edilecek_kdv) ");
            sb.Append(" VALUES        (0, - 1, 0, 0, 1002, 0, 0, 0, 0,@user,@createDate,@user,@updateDate, '', '', '', 0, 0,@belgeTarihi,@tip,@cins,@normalIade,@evrakTip,@evrakSeri,@evrakSira,@evrakSatir,@belgeNo,@belgeTarihi,@stokKodu, 0,  ");
            sb.Append("                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,@cariKodu, 0, '', '0', 0, 0, 0, 0, 0,@miktar, 0, 1,@tutar, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,@kdvSira,@kdvTutari, 0, 0, 0, 0,@barkod, 0, 0, 0, 0, 0,@depo,@belgeTarihi, '', '',  ");
            sb.Append("                          '18991230', 0, 0, 0, 0, 0, 0, '', 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0) ");
            sb.Append(" ELSE ");
            sb.AppendFormat(" UPDATE    S_{0} ", tableName);
            sb.Append(" SET                sth_RECid_DBCno = 0, sth_SpecRECno = 0, sth_iptal = 0, sth_fileid = 1002, sth_hidden = 0, sth_kilitli = 0, sth_degisti = 0, sth_checksum = 0, sth_create_user = @user, sth_create_date = @createDate,  ");
            sb.Append("  sth_lastup_user = @user, sth_lastup_date = @updateDate, sth_special1 = '', sth_special2 = '', sth_special3 = '', sth_firmano = 0, sth_subeno = 0, sth_tarih = @belgeTarihi, sth_tip = @tip, sth_cins = @cins,  ");
            sb.Append("  sth_normal_iade = @normalIade, sth_belge_no = @belgeNo, sth_belge_tarih = @belgeTarihi, sth_stok_kod = @stokKodu, sth_isk_mas1 = 0, sth_isk_mas2 = 0, sth_isk_mas3 = 0, sth_isk_mas4 = 0,  ");
            sb.Append("  sth_isk_mas5 = 0, sth_isk_mas6 = 0, sth_isk_mas7 = 0, sth_isk_mas8 = 0, sth_isk_mas9 = 0, sth_isk_mas10 = 0, sth_sat_iskmas1 = 0, sth_sat_iskmas2 = 0, sth_sat_iskmas3 = 0, sth_sat_iskmas4 = 0,  ");
            sb.Append("  sth_sat_iskmas5 = 0, sth_sat_iskmas6 = 0, sth_sat_iskmas7 = 0, sth_sat_iskmas8 = 0, sth_sat_iskmas9 = 0, sth_sat_iskmas10 = 0, sth_pos_satis = 0, sth_cari_cinsi = 0, sth_cari_kodu = @cariKodu,  ");
            sb.Append("  sth_cari_grup_no = 0, sth_isemri_gider_kodu = '', sth_plasiyer_kodu = '0', sth_har_doviz_cinsi = 0, sth_har_doviz_kuru = 0, sth_alt_doviz_kuru = 0, sth_stok_doviz_cinsi = 0, sth_stok_doviz_kuru = 0,  ");
            sb.Append("  sth_miktar = @miktar, sth_miktar2 = 0, sth_birim_pntr = 1, sth_tutar = @tutar, sth_iskonto1 = 0, sth_iskonto2 = 0, sth_iskonto3 = 0, sth_iskonto4 = 0, sth_iskonto5 = 0, sth_iskonto6 = 0, sth_masraf1 = 0,  ");
            sb.Append("  sth_masraf2 = 0, sth_masraf3 = 0, sth_masraf4 = 0, sth_vergi_pntr = @kdvSira, sth_vergi = @kdvTutari, sth_masraf_vergi_pntr = 0, sth_masraf_vergi = 0, sth_netagirlik = 0, sth_odeme_op = 0,  ");
            sb.Append("  sth_aciklama = @barkod, sth_sip_recid_dbcno = 0, sth_sip_recid_recno = 0, sth_fat_recid_dbcno = 0, sth_fat_recid_recno = 0, sth_giris_depo_no = 0, sth_cikis_depo_no = @depo,  ");
            sb.Append("  sth_malkbl_sevk_tarihi = @belgeTarihi, sth_cari_srm_merkezi = '', sth_stok_srm_merkezi = '', sth_fis_tarihi = '18991230', sth_fis_sirano = 0, sth_vergisiz_fl = 0, sth_maliyet_ana = 0, sth_maliyet_alternatif = 0,  ");
            sb.Append("  sth_maliyet_orjinal = 0, sth_adres_no = 0, sth_parti_kodu = '', sth_lot_no = 0, sth_kons_recid_dbcno = 0, sth_kons_recid_recno = 0, sth_proje_kodu = '', sth_exim_kodu = '', sth_otv_pntr = 0, sth_otv_vergi = 0,  ");
            sb.Append("  sth_brutagirlik = 0, sth_disticaret_turu = 0, sth_otvtutari = 0, sth_otvvergisiz_fl = 0, sth_oiv_pntr = 0, sth_oiv_vergi = 0, sth_oivvergisiz_fl = 0, sth_fiyat_liste_no = 0 ");
            sb.Append(" WHERE     (sth_evrakno_seri = @evrakSeri) AND (sth_evrakno_sira = @evrakSira) AND (sth_satirno = @evrakSatir)");
            sb.AppendFormat(";update S_{0} set sth_RECid_RECno=sth_RECno where sth_RECid_RECno=-1", tableName);

            using (SqlCommand cmd = new SqlCommand(sb.ToString(), trn))
            {
                cmd.CommandTimeout = 9999;
                //cmd.Transaction = trn;
                cmd.Parameters.Add("@user", System.Data.SqlDbType.Int);
                cmd.Parameters.Add("@createDate", System.Data.SqlDbType.DateTime);
                cmd.Parameters.Add("@updateDate", System.Data.SqlDbType.DateTime);
                cmd.Parameters.Add("@belgeTarihi", System.Data.SqlDbType.DateTime);
                cmd.Parameters.Add("@tip", System.Data.SqlDbType.TinyInt);
                cmd.Parameters.Add("@cins", System.Data.SqlDbType.TinyInt);
                cmd.Parameters.Add("@normalIade", System.Data.SqlDbType.TinyInt);
                cmd.Parameters.Add("@evrakTip", System.Data.SqlDbType.TinyInt);
                cmd.Parameters.Add("@belgeNo", System.Data.SqlDbType.VarChar, 15);
                cmd.Parameters.Add("@stokKodu", System.Data.SqlDbType.VarChar, 25);
                cmd.Parameters.Add("@cariKodu", System.Data.SqlDbType.VarChar, 25);
                cmd.Parameters.Add("@miktar", System.Data.SqlDbType.Float);
                cmd.Parameters.Add("@tutar", System.Data.SqlDbType.Float);
                cmd.Parameters.Add("@kdvSira", System.Data.SqlDbType.TinyInt);
                cmd.Parameters.Add("@kdvTutari", System.Data.SqlDbType.Float);
                cmd.Parameters.Add("@barkod", System.Data.SqlDbType.VarChar, 25);
                cmd.Parameters.Add("@depo", System.Data.SqlDbType.Int);
                cmd.Parameters.Add("@evrakSeri", System.Data.SqlDbType.VarChar, 4);
                cmd.Parameters.Add("@evrakSira", System.Data.SqlDbType.Int);
                cmd.Parameters.Add("@evrakSatir", System.Data.SqlDbType.Int);

                foreach (HareketDetay item in line.Satirlar)
                {
                    cmd.Parameters["@user"].Value = mikroKullanici;
                    cmd.Parameters["@createDate"].Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                    cmd.Parameters["@updateDate"].Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                    cmd.Parameters["@belgeTarihi"].Value = line.Tarih;
                    if (line.BelgeTipi == 2)
                    {
                        cmd.Parameters["@tip"].Value = 0;
                        cmd.Parameters["@cins"].Value = 1;
                        cmd.Parameters["@normalIade"].Value = 1;
                        cmd.Parameters["@evrakTip"].Value = 13;
                    }
                    else
                    {
                        cmd.Parameters["@tip"].Value = 1;
                        cmd.Parameters["@cins"].Value = 1;
                        cmd.Parameters["@normalIade"].Value = 0;
                        cmd.Parameters["@evrakTip"].Value = 1;
                    }
                    cmd.Parameters["@belgeNo"].Value = line.BelgeNo;
                    cmd.Parameters["@stokKodu"].Value = item.StokKodu;
                    cmd.Parameters["@cariKodu"].Value = line.CariKodu;
                    cmd.Parameters["@miktar"].Value = item.Miktar;
                    cmd.Parameters["@tutar"].Value = item.Tutar;
                    cmd.Parameters["@kdvSira"].Value = item.KdvDepartmani;
                    cmd.Parameters["@kdvTutari"].Value = item.KdvTutari;
                    cmd.Parameters["@barkod"].Value = item.Barkodu;
                    cmd.Parameters["@depo"].Value = depoNo;
                    cmd.Parameters["@evrakSeri"].Value = evrakSeri;
                    cmd.Parameters["@evrakSira"].Value = evrakSira;
                    cmd.Parameters["@evrakSatir"].Value = item.LineNo;
                    cmd.ExecuteNonQuery();
                }
            }
        }
    }
}
